package com.ciwong.epaper.util;

import android.content.Context;
import android.util.SparseArray;

import com.ciwong.epaper.R;
import com.ciwong.epaper.application.EApplication;
import com.ciwong.mobilelib.utils.BaseConstants;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

/**
 * 新电子报 相关常量类
 *
 * @author bin
 * @version ciwong v.1.0 2015/7/25 11:46
 * @since ciwong v.1.0
 */
public class EConstants extends BaseConstants {

    public static final int LIMIT_GOLD = 2000;
    public static final int LIMIT_TIME = 2;
    public static final int LIMIT_CANDY = 10;
    public static final float NIGHT_NUM = 0.05f;

    /**
     * 表情大小
     */
    public static final int DEFAULT_FACE_SIZE = 18;

    //测试
//    public static final String WEBSOCKET_URL = "ws://192.168.2.228:8181";

//    public static final String WEBSOCKET_URL = "ws://47.94.78.25:8181";
    /**
     * ciwong头像地址
     */
    public static final String PICTUR_RULE = "http://rimg2.ciwong.net/cwf";

    /**
     * ciwong头像地址
     */
    public static final String AVATAR_RULE = "http://avatar.ciwong.net/";

    /**
     * 头像缩略图
     */
    public static final ImageSize headImageSize = new ImageSize(100, 100);

    /**
     * 使用时注意还有添加
     */
    public static final String RES_SCHEME_NEW = "res:///";

    /**
     * 使用时注意还有添加“/”
     */
    public static final String RES_SCHEME = "res://";

    public static final String FILE_SCHEME = "file://";

    /**
     * 在线客服url
     */
    public static final String ONLINE_SERVICE = "http://ehelp.ciwong.com/kf";
    // public static final String ONLINE_SERVICE =
    // "http://chat.live800.com/live800/chatClient/chatbox.jsp?companyID=92071&configID=119357&jid=2459128748";

    /**
     * 弱密码口令检测配置文件
     */
    public static final String PASSWORDPROPERTIES = "file:///android_asset/password.properties";

    /**
     * 做作业所需最低空间大小(byte)
     */
    public static final long DO_WORK_MIN_SIZE = 20 * 1024 * 1024;

    /**
     * 下载作业需要的空间对于资源大小的倍数
     */
    public static final int DOWNLOAD_SIZE_MULTIPLE = 5;

    /**
     * 一次最多请求数目
     */
    public static final int MAX_REQUEST_BOOK_COUNT = 12;

    /**
     * 客户端ID
     */
    public static String CLIENT_ID;

    /**
     * 请求的client密码
     */
    public static String CLIENT_SECRECT;

    /**
     * sgin hmacSha1密码
     */
    public static String HMACSHA1_SECRECT = "ujeE8SfKK0b8z7mO";

    public static boolean IS_YOUKE;
    /**
     * 听说模考游客登陆不去记录表示
     */

    public static boolean LISTENSPEAK_IS_YOUKE_LOGIN = false;
    /**
     * 单词游客登陆不去记录表示
     */

    public static boolean WORD_IS_YOUKE_LOGIN = false;
    /**
     * 句子模考游客登陆不去记录表示
     */

    public static boolean SENTENCE_IS_YOUKE_LOGIN = false;
    /**
     * 游客客户端ID
     */
    public static String YOUKE_CLIENT_ID = "100154";
    /**
     * 请求的client密码
     */
    public static String YOUKE_CLIENT_SECRECT = "e594b700201911e8aefe0fe78f95ad4d";

    /**
     * 临时保存正常客户端ID
     */
    public static String NOMOR_CLIENT_ID;
    /**
     * 临时保存正常请求的client密码
     */
    public static String NOMOR_CLIENT_SECRECT;


    /**
     * 保存自动登录标识
     */
    public static final String SHARE_KEY_AUTO_LOGIN = "SHARE_KEY_AUTO_LOGIN";

    /**
     * 自动登录类型标识
     */
    public static final String SHARE_KEY_AUTO_LOGIN_TYPE = "SHARE_KEY_AUTO_LOGIN_TYPE";

    /**
     * 保存自动用户名
     */
    // public static final String SHARE_KEY_AUTO_LOGIN_USERID =
    // "SHARE_KEY_AUTO_LOGIN_USERID";

    /**
     * 保存自动密码
     */
    // public static final String SHARE_KEY_AUTO_LOGIN_PASSWORD =
    // "SHARE_KEY_AUTO_LOGIN_PASSWORD";

    /**
     * 保存设置：是否回放自己的录音
     */
    public static final String SHARE_KEY_PLAY_BACK_AUDIO = "SHARE_KEY_PLAY_BACK_AUDIO";

    /**
     * 保存设置：跟读完后是否评价
     */
    public static final String SHARE_KEY_IS_ASSESS = "SHARE_KEY_IS_ASSESS";

    /**
     * 保存设置：是否播放大题题干
     */
    public static final String SHARE_KEY_IS_PLAY_STEM_AUDIO = "SHARE_KEY_IS_PLAY_STEM_AUDIO";

    public static final String SHARE_KEY_IS_OPEN_INTENSIVE_READING_MODE = "SHARE_KEY_IS_OPEN_INTENSIVE_READING_MODE";

    /**
     * 是否展示过引导页
     */
    public static final String SHARE_KEY_IS_SHOW_LSW_TIP = "SHARE_KEY_IS_SHOW_LSW_TIP";

    /**
     * 收藏列表是否显示提示
     */
    public static final String SHARE_KEY_FAVORITES_IS_SHOW_LSW_TIP = "SHARE_KEY_FAVORITES_IS_SHOW_LSW_TIP";

    /**
     * 作业内容是否显示提示
     */
    public static final String SHARE_KEY_WORK_CONTENT_IS_SHOW_LSW_TIP = "SHARE_KEY_WORK_CONTENT_IS_SHOW_LSW_TIP";

    /**
     * 是否展示过引导页 新书桌页面
     */
    public static final String SHARE_KEY_IS_SHOW_NEW_BOOK_DESK = "SHARE_KEY_IS_SHOW_NEW_BOOK_DESK";
    /**
     * 是否展示过引导页 新书桌页面练习册更名
     */
    public static final String SHARE_KEY_IS_SHOW_NEW_BOOK_DESK_WORDBOOK_CHANGE_NAME = "SHARE_KEY_IS_SHOW_NEW_BOOK_DESK_WORDBOOK_CHANGE_NAME";

    /**
     * 是否展示过引导页 选择词汇
     */
    public static final String SHARE_KEY_IS_SHOW_SELECT_WORD_BOOK = "SHARE_KEY_IS_SHOW_SELECT_WORD_BOOK";
    /**
     * 是否展示过引导页 制定计划
     */
    public static final String SHARE_KEY_IS_SHOW_MAKE_WORD_PLAN = "SHARE_KEY_IS_SHOW_MAKE_WORD_PLAN";

    /**
     * 是否展示过引导页--选择题目
     */
    public static final String SHARE_KEY_IS_SHOW_LSW_TIP_SELECT = "SHARE_KEY_IS_SHOW_LSW_TIP_SELECT";
    /**
     * 是否是首次显示同步跟读帮助信息
     */
    public static final String SHARE_KEY_REPEAT_READ_HELP_TIP = "SHARE_KEY_REPEAT_READ_HELP_TIP";

    /**
     * 是否是首次显示点击停止录音提示消息
     */
    public static final String SHARE_KEY_STOP_RECORD_TIP = "SHARE_KEY_STOP_RECORD_TIP";
    /**
     * 是否是单词跟读首次显示完成录音提示消息
     */
    public static final String SHARE_KEY_SHOW_FINISH_RECORD_TIP = "SHARE_KEY_SHOW_FINISH_RECORD_TIP";


    /**
     * 是否布置过作业
     */
    public static final String SHARE_KEY_HAS_ASSIGN_HOMEWORK = "SHARE_KEY_HAS_ASSIGN_HOMEWORK";
    /**
     * 是否有历史作业
     */
    public static final String SHARE_KEY_HAS_OLD_HOMEWORK = "SHARE_KEY_HAS_OLD_HOMEWORK";


    /**
     * 阅读下一步提示
     */
    public static final String SHARE_KEY_LSW_TIPS_READ = "SHARE_KEY_LSW_TIPS_READ";


    /**
     * 阅读下一步提示
     */
    public static final String SHARE_KEY_REPEAT_TIPS = "SHARE_KEY_REPEAT_TIPS_NEW";
    /**
     * 播放题干提示
     */
    public static final String SHARE_KEY_LSW_TIPS_PLAY = "SHARE_KEY_LSW_TIPS_PLAY";


    /**
     * 准备
     */
    public static final String SHARE_KEY_LSW_TIPS_PREPARE = "SHARE_KEY_LSW_TIPS_PREPARE";


    /**
     * 提前完成录音提示
     */
    public static final String SHARE_KEY_LSW_TIPS_RECORD = "SHARE_KEY_LSW_TIPS_RECORD";


    /**
     * 提前完成答题提示
     */
    public static final String SHARE_KEY_LSW_TIPS_ANSWER = "SHARE_KEY_LSW_TIPS_ANSWER";
    /**
     * 提前完成答题提示
     */
    public static final String SHARE_KEY_DATA_DAY_SIGN_IN = "SHARE_KEY_DATA_DAY_SIGN_IN";

    public static final String SHARE_KEY_MSG_TYPE_HOMEWORK_MSG_GROUP_ID = "SHARE_KEY_MSG_TYPE_HOMEWORK_MSG_GROUP_ID";
    public static final String SHARE_KEY_MSG_TYPE_SERVICE_MSG_GROUP_ID = "SHARE_KEY_MSG_TYPE_SERVICE_MSG_GROUP_ID";
    public static final String SHARE_KEY_MSG_HAS_GET_SUCESSFUL_ONCE = "SHARE_KEY_MSG_HAS_GET_SUCESSFUL_ONCE";
    /**
     * 登录时密码错误包含特殊字符
     */
    public static final int LOGIN_ERROR_CODE_PWD_ERROR_SPECIAL = 1008;

    /**
     * 登录时密码错误
     */
    public static final int LOGIN_ERROR_CODE_PWD_ERROR = 10004;

    public static final int UNBIND_PHONE_CODE_ERROR = 60002;

    /**
     * 登录时账号错误
     */
    public static final int LOGIN_ERROR_CODE_ACCOUNT_ERROR = 110006;


    /**
     * 登录时密码错误包含特殊字符
     */
    public static final int ERROR_CODE_REPEAT_COMMIT = 52;

    /**
     * 本地JSON资源版本
     */
    public static final String JSON_VERSION = "1.0";

    /**
     * 音频默认后缀
     */
    public static final String AUDIO_DEFAULT_SUFFIX = ".mp3";
    /**
     * 拍照默认后缀
     */
    public static final String CAMERA_DEFAULT_SUFFIX = ".jpg";

    /**
     * opus 音频流结尾后缀
     */
    public static final String OPUS_DEFAULT = "oups";
    /**
     * 图片默认后缀
     */
    public static final String IMG_DEFAULT_SUFFIX = ".jpg";

    /**
     * 习网条款
     */
    public static final String RULE = "file:///android_asset/rule.html";

    /**
     * 微信APP_ID
     */
    public static String WEIXIN_APP_ID = "wx0e742334d058a4e0";

    /**
     * QQ登录ID
     */
    public static String QQ_APP_ID = "1104752065";

    /**
     * 微信测试APP_ID
     */
    // public static final String WEIXIN_APP_ID = "wx7e97dc6531f3cf94";

    /**
     * QQ登录测试ID
     */
    // public static final String QQ_APP_ID = "1104752217";

    /**
     * 当前品牌的单词句子的评分系数
     */
    public static final String SHARE_KEY_SOCRE_COEFFICIENT = "SHARE_KEY_SOCRE_COEFFICIENT_" + EApplication.BRAND_ID;

    public static SparseArray<String> GRADE_DATA = new SparseArray<String>() {
        {
            put(1101, "一年级");
            put(1102, "二年级");
            put(1103, "三年级");
            put(1104, "四年级");
            put(1105, "五年级");
            put(1106, "六年级");
            put(1107, "七年级");
            put(1108, "八年级");
            put(1109, "九年级");
            put(1111, "高一");
            put(1112, "高二");
            put(1113, "高三");
            put(1114, "小班");
            put(1115, "中班");
            put(1116, "大班");
            put(1117, "学前班");
            put(1118, "大一");
            put(1119, "大二");
            put(1120, "大三");
            put(1121, "大四");
            put(2, "品牌英语");
            put(-1, "品牌语文");
        }
    };

    private static DisplayImageOptions cricleFaceOption;

    /**
     * 服务logo圆角option
     */
    private static DisplayImageOptions serviceLogoOption;

    /**
     * 书籍封面option
     */
    private static DisplayImageOptions bookCoverOption;

    private static DisplayImageOptions emptyUriOption;
    /**
     * 下发短信倒计时时间
     */
    public static final int COUNT_COUNTDOWN = 60;


    /**
     * 获取默认头像圆角Option
     *
     * @return 默认头像圆角Option
     */
    public static DisplayImageOptions getDefAvatarCircleBuilder() {
        if (cricleFaceOption == null) {
            cricleFaceOption = getDisplayBuilder()
                    .showImageOnLoading(R.mipmap.head)
                    .showImageForEmptyUri(R.mipmap.head)
                    .showImageOnFail(R.mipmap.head).cacheInMemory(true)
                    .cacheOnDisk(true)
                    .displayer(new RoundedBitmapDisplayer(20)).build();
        }
        return cricleFaceOption;
    }

    /**
     * 获取服务logo圆角Option
     *
     * @return
     */
    public static DisplayImageOptions getServiceLogoOption(Context context) {
        if (serviceLogoOption == null) {
            serviceLogoOption = new DisplayImageOptions.Builder()
                    .cacheInMemory(true).cacheOnDisk(true)
                    .displayer(new RoundedBitmapDisplayer(
                            context.getResources().getDimensionPixelSize(
                                    R.dimen.bookcase_server_radius)))
                    .showImageForEmptyUri(R.mipmap.brand_loading)
                    .showImageOnFail(R.mipmap.brand_loading_error).build();
        }
        return serviceLogoOption;
    }

    /**
     * 获取书籍封面Option
     *
     * @return
     */
    public static DisplayImageOptions getBookCoverOption() {
        if (bookCoverOption == null) {
            bookCoverOption = new DisplayImageOptions.Builder()
                    .cacheInMemory(true).cacheOnDisk(true)
                    .showImageForEmptyUri(R.mipmap.item_load_icon)
                    .showImageOnLoading(R.mipmap.item_load_icon)
                    .showImageOnFail(R.mipmap.item_load_icon).build();
        }
        return bookCoverOption;
    }

    public static DisplayImageOptions getEmptyUriOption() {
        if (emptyUriOption == null) {
            emptyUriOption = new DisplayImageOptions.Builder()
                    .cacheInMemory(true).cacheOnDisk(true)
                    .showImageForEmptyUri(R.mipmap.brand_loading)
                    .showImageOnLoading(R.mipmap.brand_loading)
                    .showImageOnFail(R.mipmap.captcha_failure).build();
        }
        return emptyUriOption;
    }

    public static DisplayImageOptions getBanOption() {
        if (bookCoverOption == null) {
            bookCoverOption = new DisplayImageOptions.Builder()
                    .cacheInMemory(true).cacheOnDisk(true)
                    .showImageForEmptyUri(R.mipmap.ic_launcher)
                    .showImageOnLoading(R.mipmap.ic_launcher)
                    .showImageOnFail(R.mipmap.ic_launcher).build();
        }
        return bookCoverOption;
    }

    public static DisplayImageOptions getDefaultpictureOption(int resId) {
        DisplayImageOptions imageOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true).cacheOnDisk(true)
                .showImageForEmptyUri(resId)
                .showImageOnLoading(resId)
                .showImageOnFail(resId).build();
        return imageOptions;
    }


    /**
     * 下发短信类型
     */
    public static class Template {
        public static final int TEMPLATE_ONE = 1;//1 绑定手机
        public static final int TEMPLATE_TWO = 2;//2 注册
        public static final int TEMPLATE_THREE = 3;//3 忘记密码.
        public static final int TEMPLATE_FOUR = 4;//换绑手机
    }

    public static class LoginFrom {
        public static final int LOGIN_FROM_REGIST = 1;//
        public static final int LOGIN_FROM_RESETPSW = 2;//
        public static final int LOGIN_FROM_SUBMIT_WORK = 3;//提交作业
    }

    /**
     * @return 根据不同的环境返回相应的链接地址
     * 作业详情
     */
    public static String getRunEnvUrl_H5_2_9() {
        return "https://m.teacher.jiaofuyun.com/v1807_2_9/";
    }

    /**
     * @return 根据不同的环境返回相应的链接地址
     * 作业详情
     */
    public static String getRunEnvUrl_H5_2_10() {
        return "https://m.teacher.jiaofuyun.com/v1811_2_10/";
    }

    /**
     * @return 根据不同的环境返回相应的链接地址
     * 微信网页
     */
    public static String getRunEnvUrl_H5_Wechat() {
        return "https://m.teacher.jiaofuyun.com/epaperwork/";
    }
}
